Repository navigation
render: restore framebuffer before viewport in frame_buffer::apply() - #204
Merged
Merged
Conversation
frame_buffer::apply() restored the viewport before the framebuffer. Renderers whose set_viewport() computes absolute coordinates from the height of the current render target (e.g. OpenGL's bottom-left origin glViewport()) therefore restored the screen viewport against the height of the cache framebuffer instead of the window, producing a wrong glViewport() that persisted until the next actual resize. This made the rendered image shift (and stay broken) on the next frame after any cached widget was rendered, and only a window resize/restore corrected it. Restore the framebuffer first and then the viewport, so the viewport restore always uses the height of the intended target.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #204 +/- ##
=======================================
Coverage 28.55% 28.55%
=======================================
Files 239 239
Lines 8945 8945
Branches 2785 2785
=======================================
Hits 2554 2554
Misses 6057 6057
Partials 334 334 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
frame_buffer::apply()restored the viewport before the framebuffer:Renderers whose
set_viewport()computes absolute coordinates from the height of the current render target (OpenGL/OpenGLES' bottom-left-originglViewport()) therefore restored the screen viewport against the height of the cache framebuffer instead of the window, producing a wrongglViewport()(e.g. negative y) that persisted until the next actual window resize.This made the rendered image shift (and stay broken) on the next frame after any cached widget was rendered, and only a window resize/restore corrected it.
Fix
Restore the framebuffer first and then the viewport, so the viewport restore always uses the height of the intended target (the screen or the previous framebuffer).
Reproduced with the OpenGL test app: widget tree with cached widgets rendered the whole window shifted down ~80% of screen; minimize/restore corrected it for a single frame, after which the next render re-corrupted the viewport. After this fix, the app renders correctly continuously.